package com.nega.commons.model;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

/**
 * @Author: Garcia
 * @CreateDate: 2019/5/9 18:25
 * @Description: what it is class?
 */
@Data
public class SearchResult implements Comparable<SearchResult> {
    /**
     * 标题
     */
    private String title;

    /**
     * URL地址
     */
    private String url;

    /**
     * 内容
     */
    private String content;

    /**
     * 来源网站
     */
    private String source;

    /**
     * 内容时间
     */
    private String time;

    /**
     * 舆情 ：1-正面内容，0-负面内容
     */
    private String lyrical;

    /**
     * 负面指数
     */
    private String negativeIndex;

    /**
     * 关键词
     */
    private String keyWord;

    private Date createTime;

    private Date updateTime;


    @Override
    public int compareTo(SearchResult result) {
        if (result == null) {
            return -1;
        }

        double a = 0;
        double b = 0;
        if (StringUtils.isNotBlank(this.negativeIndex)) {
            a = Double.valueOf(this.negativeIndex);
        }
        if (StringUtils.isNotBlank(result.getNegativeIndex())) {
            b = Double.valueOf(result.getNegativeIndex());
        }

        return a > b ? 1 : a == b ? 0 : -1;
    }
}
